package com.xunwulian.web.entity;

import com.xunwulian.base.constant.SmsStatus;
import com.xunwulian.base.constant.SmsType;
import com.xunwulian.base.entity.SmsPocessorEntity;
import com.xunwulian.base.util.DateStyle;
import com.xunwulian.base.util.DateUtil;
import com.xunwulian.base.util.EnumUtils;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.beanutils.converters.DateConverter;

/**
 * Created by Administrator on 2017/4/26.
 */
public class SmsPocessorEntityWraper extends SmsPocessorEntity {

    private String createTimeStr;

    private String statusStr;

    private String typeStr;

    public SmsPocessorEntityWraper() {

    }

    public SmsPocessorEntityWraper(SmsPocessorEntity entity) {

        try {
            ConvertUtils.register(new DateConverter(null), java.util.Date.class);
            BeanUtils.copyProperties(this, entity);
        } catch (Exception e) {
            e.printStackTrace();
        }

        createTimeStr = getCreateTime() == null ? "" : DateUtil.DateToString(getCreateTime(), DateStyle.YYYY_MM_DD_HH_MM_SS_EN);

        statusStr = "";
        SmsStatus smsStatus = EnumUtils.getEnumByType(SmsStatus.class, getStatus());
        if (smsStatus != null) {
            statusStr = smsStatus.getDesc();
        }

        typeStr = "";
        SmsType smsType = EnumUtils.getEnumByType(SmsType.class, getType());
        if (smsType != null) {
            typeStr = smsType.getDesc();
        }
    }

    public String getCreateTimeStr() {
        return createTimeStr;
    }

    public void setCreateTimeStr(String createTimeStr) {
        this.createTimeStr = createTimeStr;
    }

    public String getStatusStr() {
        return statusStr;
    }

    public void setStatusStr(String statusStr) {
        this.statusStr = statusStr;
    }

    public String getTypeStr() {
        return typeStr;
    }

    public void setTypeStr(String typeStr) {
        this.typeStr = typeStr;
    }
}